package com.meshnetics.gb.stack.mac.type;

import com.meshnetics.gb.type.DataValue;
import com.meshnetics.gb.type.impl.custom.ListDataValue;

import java.nio.ByteBuffer;

/**
 * The list of descriptors - result of active/passive/orphan scan.
 *
 * @author AKovylin
 */
public class PANDescriptorList extends ListDataValue {
    public PANDescriptorList(PANDescriptor[] elements) {
        super(TypePANDescriptorList.TYPE, elements);
    }

    PANDescriptorList(TypePANDescriptorList listType, DataValue[] elements) {
        super(listType, elements);
    }

    public PANDescriptor[] listPANDescriptors() {
        PANDescriptor[] res = new PANDescriptor[getListSize()];
        for (int i = 0; i < res.length; i++) {
            res[i] = (PANDescriptor) getElement(i);
        }
        return res;
    }

    public int getDataSize() {
        int size = 0;
        for (int i = 0; i < getListSize(); i++) {
            size += getElement(i).getDataSize();
        }
        return size;
    }

    public Object toObject() {
        throw new UnsupportedOperationException("not implemented yet");
        // todo reimplement
    }

    public void serialize(ByteBuffer bb) {
        throw new UnsupportedOperationException("unsupported, serialization not expected");
    }
}
